package com.jie.common.util;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

import static com.jie.common.constant.StrConst.DEFAULT_PREFIX_DISTINCTION_NAME;
import static com.jie.common.constant.StrConst.PREFIX_DISTINCTION_NAME;

/**
 * @author jie
 * @version 1.0 2025-02-09 Spring工具，获取spring的进程信息
 */
public class SpringUtil implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    private static ConfigurableApplicationContext configurableApplicationContext;


    public static String getPrefixDistinctionName(){
        return configurableApplicationContext.getEnvironment().getProperty(PREFIX_DISTINCTION_NAME,
                DEFAULT_PREFIX_DISTINCTION_NAME);
    }

    @Override
    public void initialize(final ConfigurableApplicationContext applicationContext) {
        LogUtil.initLog("SpringUtil");
        configurableApplicationContext = applicationContext;
    }
}
